<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <el-menu
          active-text-color="#409ee4"
          background-color="#1f2d3d"
          class="el-menu-vertical-demo"
          default-active="2"
          text-color="#fff"
          @open="handleOpen"
          @close="handleClose"
          :router="true"
        >
          <el-sub-menu index="1">
            <template #title>
              <span>系统管理</span>
            </template>
            <div v-for="(item, index) in userUsers.menulist" :key="index">
              <el-menu-item :index="item.purl">{{ item.pname }}</el-menu-item>
            </div>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <RouterView />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang='ts' setup>
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from "@element-plus/icons-vue";
import { onMounted, ref, reactive } from "vue";
import { useUser } from "../../stores/user";

const userUsers = useUser();

// 数据
const list: any = reactive({
  tableDate: [],
});

onMounted(async () => {
  await userUsers.addMenuFn();
});

// 展开列表
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};

// 合上列表
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
</script>

<style scoped>
.el-aside {
  height: 97vh;
  background-color: #304156;
}
</style>